﻿#region sqlserver
//using System;
//using Microsoft.EntityFrameworkCore;
//using Microsoft.EntityFrameworkCore.Metadata;

//// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
//// If you have enabled NRTs for your project, then un-comment the following line:
//// #nullable disable

//namespace NewsEntity.Models
//{
//    public partial class NewsContext : DbContext
//    {
//        public NewsContext()
//        {
//        }

//        public NewsContext(DbContextOptions<NewsContext> options)
//            : base(options)
//        {
//        }

//        public virtual DbSet<BannerManager> BannerManager { get; set; }
//        public virtual DbSet<NewInfo> NewInfo { get; set; }
//        public virtual DbSet<News> News { get; set; }
//        public virtual DbSet<NewsType> NewsType { get; set; }
//        public virtual DbSet<Adminlogin> Adminlogin { get; set; }
//        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
//        {
//            if (!optionsBuilder.IsConfigured)
//            {

//                optionsBuilder.UseSqlServer("server=.;Database=News; user id=sa; Password=123456");
//            }
//        }

//        protected override void OnModelCreating(ModelBuilder modelBuilder)
//        {
//            modelBuilder.Entity<BannerManager>(entity =>
//            {
//                entity.Property(e => e.ID).HasColumnName("ID");

//                entity.Property(e => e.AddTime).HasColumnType("datetime");

//                entity.Property(e => e.Image)
//                    .HasMaxLength(50)
//                    .IsUnicode(false);

//                entity.Property(e => e.Remark)
//                    .HasMaxLength(50)
//                    .IsUnicode(false);

//                entity.Property(e => e.Url)
//                    .HasMaxLength(100)
//                    .IsUnicode(false);
//            });

//            modelBuilder.Entity<NewInfo>(entity =>
//            {
//                entity.Property(e => e.Id).HasColumnName("ID");

//                entity.Property(e => e.Content).HasColumnType("text");

//                entity.Property(e => e.CreateTime).HasColumnType("datetime");

//                entity.Property(e => e.Remarks)
//                    .HasMaxLength(50)
//                    .IsUnicode(false);
//            });

//            modelBuilder.Entity<News>(entity =>
//            {
//                entity.Property(e => e.Id).HasColumnName("ID");

//                entity.Property(e => e.Image)
//                    .HasMaxLength(60)
//                    .IsUnicode(false);

//                entity.Property(e => e.NewsContent).HasColumnType("text");

//                entity.Property(e => e.NewsTitle)
//                    .HasMaxLength(50)
//                    .IsUnicode(false);

//                entity.Property(e => e.PublishDate).HasColumnType("datetime");

//                entity.Property(e => e.Remark)
//                    .HasMaxLength(50)
//                    .IsUnicode(false);
//            });

//            modelBuilder.Entity<NewsType>(entity =>
//            {
//                entity.HasKey(e => e.TypeId);

//                entity.Property(e => e.TypeName)
//                    .HasMaxLength(20)
//                    .IsUnicode(false)
//                    .IsFixedLength();
//            });

//            OnModelCreatingPartial(modelBuilder);
//        }

//        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
//    }
//}

#endregion


#region mysql

using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Pomelo.EntityFrameworkCore.MySql.Storage;

namespace NewsEntity.Models
{
    public partial class NewsContext : DbContext
    {
        public NewsContext()
        {
        }

        public NewsContext(DbContextOptions<NewsContext> options)
            : base(options)
        {
        }

        public virtual DbSet<BannerManager> BannerManager { get; set; }
        public virtual DbSet<NewInfo> NewInfo { get; set; }
        public virtual DbSet<News> News { get; set; }
        public virtual DbSet<NewsType> NewsType { get; set; }
        public virtual DbSet<Adminlogin> Adminlogin { get; set; }
        public virtual DbSet<OnlineUsers> OnlineUsers { get; set; }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                //var connectionString = "Data Source=117.72.42.23;Database=news;User ID=wuwei;Password=123456;pooling=true;port=3306;sslmode=none;CharSet=utf8mb4;";

                //var connectionString = "Data Source=117.72.42.23;Database=news;User ID=wuwei;Password=123456;pooling=true;port=3306;sslmode=none;CharSet=utf8;";
                var connectionString = "Data Source=49.65.97.75;Database=news;User ID=root;Password=Ww623025.;pooling=true;port=3306;sslmode=none;CharSet=utf8;";
                optionsBuilder.UseMySql(connectionString,
                    mysqlOptions => mysqlOptions.EnableRetryOnFailure(
                        maxRetryCount: 5,
                        maxRetryDelay: TimeSpan.FromSeconds(10),
                        errorNumbersToAdd: null));
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<BannerManager>(entity =>
            {
                entity.Property(e => e.ID).HasColumnName("ID");

                entity.Property(e => e.AddTime).HasColumnType("datetime");

                entity.Property(e => e.Image)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Remark)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Url)
                    .HasMaxLength(100)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<NewInfo>(entity =>
            {
                entity.Property(e => e.Id).HasColumnName("ID");

                entity.Property(e => e.Content).HasColumnType("text");

                entity.Property(e => e.CreateTime).HasColumnType("datetime");

                entity.Property(e => e.Remarks)
                    .HasMaxLength(50)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<News>(entity =>
            {
                entity.Property(e => e.Id).HasColumnName("ID");

                entity.Property(e => e.Image)
                    .HasMaxLength(60)
                    .IsUnicode(false);

                entity.Property(e => e.NewsContent).HasColumnType("text");
                entity.Property(e => e.NewsStatus).HasColumnType("int");
                entity.Property(e => e.NewsTitle)
                    .HasMaxLength(500)
                    .IsUnicode(false);

                entity.Property(e => e.PublishDate).HasColumnType("datetime");

                entity.Property(e => e.Remark)
                    .HasMaxLength(50)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<NewsType>(entity =>
            {
                entity.HasKey(e => e.TypeId);

                entity.Property(e => e.TypeName)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .IsFixedLength();
            });

            modelBuilder.Entity<Adminlogin>(entity =>
            {
                entity.HasKey(e => e.id);

                entity.Property(e => e.PassWord)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .IsFixedLength();
            });
            modelBuilder.Entity<OnlineUsers>(entity =>
            {
                entity.HasKey(e => e.UserID);

            });
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}

#endregion